package br.com.abelha.manager.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * @author dalsonsouza
 */

public class AbelhaDBHelper extends SQLiteOpenHelper {

	private static final String DB_NAME = "abelha";
	private static final int DB_VERSION = 1;
	
	public AbelhaDBHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase sqLiteDatabase) {
		sqLiteDatabase.execSQL(DBCreate.FORM_A);
		sqLiteDatabase.execSQL(DBCreate.ABAST_AGUA);
		sqLiteDatabase.execSQL(DBCreate.DESTINO_FEZES);
		sqLiteDatabase.execSQL(DBCreate.DESTINO_LIXO);
		sqLiteDatabase.execSQL(DBCreate.PLANO_SAUDE);
		sqLiteDatabase.execSQL(DBCreate.TRAT_AGUA);
		sqLiteDatabase.execSQL(DBCreate.USUARIOS);
		sqLiteDatabase.execSQL(DBCreate.RACA);
		sqLiteDatabase.execSQL(DBCreate.PESSOAS);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHAB_DIA);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHAB_GES);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHAB_HA);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHAB_HAN);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHAB_CRIANCA);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHAB_INT);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHADPROC);		
		sqLiteDatabase.execSQL(DBCreate.TBLFICHADMED);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHAB_TB);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHADENF);
		sqLiteDatabase.execSQL(DBCreate.TBLFICHACOMP_MATR);
		sqLiteDatabase.execSQL("insert into tblSeg_Usuarios values(null,\'marcelo\',\'1234\',\'Marcelo Limamp\',0);");
		sqLiteDatabase.execSQL("insert into tblSeg_Usuarios values(null,\'dalson\',\'1234\',\'Dalson Souza\',0);");
		sqLiteDatabase.execSQL("insert into tblSeg_Usuarios values(null,\'zanetta\',\'1234\',\'Zanetta Teste\',0);");
		sqLiteDatabase.execSQL("insert into tblPac_AbastAgua values(null,\'Rede Geral\');");
		sqLiteDatabase.execSQL("insert into tblPac_AbastAgua values(null,\'Poco ou Nascente\');");
		sqLiteDatabase.execSQL("insert into tblPac_AbastAgua values(null,\'Outros\');");
		sqLiteDatabase.execSQL("insert into tblPac_DestinoFezes values(null,\'Sistema de Esgoto\');");
		sqLiteDatabase.execSQL("insert into tblPac_DestinoFezes values(null,\'Fossa\');");
		sqLiteDatabase.execSQL("insert into tblPac_DestinoFezes values(null,\'Ceu Aberto\');");
		sqLiteDatabase.execSQL("insert into tblPac_DestinoLixo  values(null,\'Queimado\');");
		sqLiteDatabase.execSQL("insert into tblPac_DestinoLixo  values(null,\'Coletado\');");
		sqLiteDatabase.execSQL("insert into tblPac_DestinoLixo  values(null,\'Ceu Aberto\');");
		sqLiteDatabase.execSQL("insert into tblPac_TratAgua  values(null,\'Filtracao\');");
		sqLiteDatabase.execSQL("insert into tblPac_TratAgua  values(null,\'Fervura\');");
		sqLiteDatabase.execSQL("insert into tblPac_TratAgua  values(null,\'Cloracao\');");
		sqLiteDatabase.execSQL("insert into tblPac_TratAgua  values(null,\'Sem Tratamento\');");
		sqLiteDatabase.execSQL("insert into tblPac_PlanoSaude   values(null,\'UNIMED\');");
		sqLiteDatabase.execSQL("insert into tblPac_PlanoSaude   values(null,\'BRADESCO\');");
		sqLiteDatabase.execSQL("insert into tblPac_PlanoSaude   values(null,\'SUL AMERICA\');");
		sqLiteDatabase.execSQL("insert into tblPac_PlanoSaude   values(null,\'MEDIAL\');");
		sqLiteDatabase.execSQL("insert into tblPac_PlanoSaude   values(null,\'OUTROS\');");
	}

	@Override
	public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
		Log.i(this.getClass().getName(), "version " + oldVersion + " to " + newVersion);
		sqLiteDatabase.execSQL("DROP DATABASE " + DB_NAME);
	}

}
